package com.yyf.mybatisdemo.Service;

import com.yyf.mybatisdemo.entity.User;
import com.yyf.mybatisdemo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    UserMapper userMapper;

    public User queryById(int id) {
        return userMapper.queryById(id);
    }

    public List<User> getAllUsers() {
        return userMapper.getAllUsers();
    }

    public int insertUser(User user){
        userMapper.insertUser(user);
        return user.getId();//插入数据并返回主键
    }

    public void updateUser(User user){
        userMapper.updateUser(user);
    }

    public void deleteUser(int id){
        userMapper.deleteUser(id);
    }

}
